package com.icourt.learn.steam;

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Test;

import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

/**
 * 简单流
 */
@Slf4j
public class SimpleStream {


    @Test
    public void test(){
        Stream<String> stringStream = Stream.of( "a","b","c","d" ).distinct();
        Predicate stall= e->{return "abc".equals( e );};
        Optional<String> list = stringStream.filter(stall).findFirst();

        String a= list.orElse( "123" );;
        a=list.orElseThrow( RuntimeException::new );


        log.debug( a );
    }
}
